package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.result.Result;
import com.atguigu.srb.core.pojo.VO.BorrowInfoApprovalVO;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author ZLHao
 * @since 2021-07-12
 */
@Api(tags = "借款申请")
@Slf4j
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {

    @Autowired
    private BorrowInfoService borrowInfoService;


    @ApiOperation("获取借款审核状态")
    @GetMapping("/list")
    public Result list(){

        List<BorrowInfo> list = borrowInfoService.listAll();

        return Result.ok().data("list",list);
    }


    @ApiOperation("获取借款审核状态")
    @GetMapping("/show/{id}")
    public Result show(@PathVariable Long id){


        HashMap<String,Object> borrowInfoDetailMap =   borrowInfoService.showById(id);
        return Result.ok().data("borrowInfoDetail",borrowInfoDetailMap);
    }


    @ApiOperation("借款信息审批")
    @PostMapping("/approval")
    public Result approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){

        borrowInfoService.approval(borrowInfoApprovalVO);

        return Result.ok().message("审批完成");
    }


}

